import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { viteMockServe } from 'vite-plugin-mock'
import { resolve } from 'path';

// 按需导入elementplus
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// const path = require('path');

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    // https://github.com/anncwb/vite-plugin-mock
    viteMockServe({}),
    // https://element-plus.gitee.io/zh-CN/guide/quickstart.html#%E6%8C%89%E9%9C%80%E5%AF%BC%E5%85%A5 按需引入
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ]
  , resolve: {
    // 定义路径别名，项目中可直接使用别名快速定位文件路径
    alias: {
      '@': resolve(__dirname, "src")
      , 'comps': resolve(__dirname, "src/components")
      , 'layout': resolve(__dirname, "src/views/layout")
      , 'utils': resolve(__dirname, "src/util")
      , 'apis': resolve(__dirname, "src/api")
      , 'declares': resolve(__dirname, "src/declare")
      , 'styles': resolve(__dirname, "src/assets/styles")
      , 'views': resolve(__dirname, "src/views")
    }
  }
})
